/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package consumo.entity;

import java.io.Serializable;
import java.util.List;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Carlos Taschetto
 */
@Entity
@Table(name = "concessionaria", catalog = "consumodb", schema = "")
@NamedQueries({
    @NamedQuery(name = "Concessionaria.findAll", query = "SELECT c FROM Concessionaria c"),
    @NamedQuery(name = "Concessionaria.findById", query = "SELECT c FROM Concessionaria c WHERE c.id = :id"),
    @NamedQuery(name = "Concessionaria.findByNome", query = "SELECT c FROM Concessionaria c WHERE c.nome = :nome"),
    @NamedQuery(name = "Concessionaria.findByAbrev", query = "SELECT c FROM Concessionaria c WHERE c.abrev = :abrev"),
    @NamedQuery(name = "Concessionaria.findByRevisaoTarifaria", query = "SELECT c FROM Concessionaria c WHERE c.revisaoTarifaria = :revisaoTarifaria")})
public class Concessionaria implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Column(name = "nome", length = 100)
    //@Size(min = 4, message = "Informar uma Razão Social Válida!")
    private String nome;
    @Column(name = "abrev", length = 20)
    //@Size(min = 2,max=20, message = "Informar uma Abreviatura com pelo menos 2 letras!")
    private String abrev;
    @Column(name = "revisao_tarifaria")
    @Temporal(TemporalType.DATE)
    //@NotNull//(message = "Informe uma data válida!")
    private Date revisaoTarifaria;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "conce")
    private List<Tarifa> tarifaList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "conce")
    private List<Icms> icmsList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "conce")
    private List<PisCofins> pisCofinsList;

    public Concessionaria() {
    }

    public Concessionaria(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getAbrev() {
        return abrev;
    }

    public void setAbrev(String abrev) {
        this.abrev = abrev;
    }

    public Date getRevisaoTarifaria() {
        return revisaoTarifaria;
    }

    public void setRevisaoTarifaria(Date revisaoTarifaria) {
        this.revisaoTarifaria = revisaoTarifaria;
    }

    public List<Tarifa> getTarifaList() {
        return tarifaList;
    }

    public void setTarifaList(List<Tarifa> tarifaList) {
        this.tarifaList = tarifaList;
    }

    public List<Icms> getIcmsList() {
        return icmsList;
    }

    public void setIcmsList(List<Icms> icmsList) {
        this.icmsList = icmsList;
    }

    public List<PisCofins> getPisCofinsList() {
        return pisCofinsList;
    }

    public void setPisCofinsList(List<PisCofins> pisCofinsList) {
        this.pisCofinsList = pisCofinsList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Concessionaria)) {
            return false;
        }
        Concessionaria other = (Concessionaria) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return abrev;
    }

}
